package top.ffhome.blog.controller;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import top.ffhome.blog.service.ViewArticleService;
import top.ffhome.common.page.PageRequest;
import top.ffhome.common.result.Result;

@CrossOrigin
@RestController
@RequestMapping("api/blog/viewarticle")
public class ViewArticleController {
	@Autowired
	private ViewArticleService viewArticleService;

	@RequiresPermissions("blog:viewlog:clean")
	@GetMapping(value = "/clean")
	public Result clean() {
		viewArticleService.clean();
		return Result.success();
	}

	@RequiresPermissions("blog:viewlog:view")
	@PostMapping(value = "/findPage")
	public Result findPage(@RequestBody PageRequest request) {
		return Result.success(viewArticleService.select(request));
	}
}
